package com.power.sifa.approve.dao;

import com.power.sifa.approve.model.Apl_agent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 委托代理人 持久层(hibernate)
 */

public interface Apl_agentDao extends JpaRepository<Apl_agent, Serializable>, JpaSpecificationExecutor<Apl_agent>, Repository<Apl_agent, Serializable>, Apl_agentDaoCustom<Apl_agent, Serializable> {

    @Modifying
    @Transactional
    @Query("delete  from Apl_agent s where  s.id in (:ids) ")
    void removeByIds(@Param("ids") List<Integer> ids);

    @Query(" from Apl_agent s where  s.applyid = :applyid ")
    List<Apl_agent> getByApplyid(@Param("applyid") String applyid);


    @Query(value = "select distinct cardno, id, name FROM Apl_agent where name like :name  group by id ", nativeQuery = true)
    List<Map<String,Object>> searchCardNoByName(@Param("name") String name);

    @Query(" from Apl_agent s where s.id in (:ids)")
    List<Apl_agent> getByIds(@Param("ids") List<String> ids);
}


